from core import *


def Field(length):
    if callable(length):
        return DynamicField(length)
    else:
        return StaticField(length)

def Array(count, subcon):
    if not callable(count):
        count = lambda ctx: count
    return DynamicArray(count, subcon)

UBInt8 = FormattedField(">", "B")
ULInt8 = FormattedField("<", "B")
SBInt8 = FormattedField(">", "b")
SLInt8 = FormattedField("<", "b")
UBInt16 = FormattedField(">", "H")
ULInt16 = FormattedField("<", "H")
SBInt16 = FormattedField(">", "h")
SLInt16 = FormattedField("<", "h")
UBInt32 = FormattedField(">", "L")
ULInt32 = FormattedField("<", "L")
SBInt32 = FormattedField(">", "l")
SLInt32 = FormattedField("<", "l")
UBInt64 = FormattedField(">", "Q")
ULInt64 = FormattedField("<", "Q")
SBInt64 = FormattedField(">", "q")
SLInt64 = FormattedField("<", "q")
BFloat32 = FormattedField(">", "f")
LFloat32 = FormattedField("<", "f")
BFloat64 = FormattedField(">", "d")
LFloat64 = FormattedField("<", "d")




